﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HtmlExtractor.Config;

namespace HtmlExtractor.Processor
{
    public class AbsoluteUriProcessor:IProcessor
    {
       

        #region IProcessor 成员

        public string GetResult(string relativeUri,ParserContext context)
        {
            string absoluteUri = context.ParseUri;
            if (string.IsNullOrEmpty(relativeUri))
                return null;
            Uri re = new Uri(relativeUri, UriKind.RelativeOrAbsolute);
            Uri ab = new Uri(absoluteUri);
            Uri u;
            if (Uri.TryCreate(ab, re, out u))
                return u.OriginalString;
            else
                throw new Exception("uri 格式化错误");
        }

        #endregion
    }
}
